package com.lst.projectlib.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.lst.projectlib.R;
import com.lst.projectlib.util.DensityUtil;

public class CaptureDialog extends Dialog implements
		View.OnClickListener {

	private View.OnClickListener mListener = null;

	public CaptureDialog(Context context, int theme,
			View.OnClickListener listener) {
		super(context, theme);
		this.mListener = listener;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.dialog_capture);

		TextView tv_local_image = (TextView) findViewById(R.id.tv_local_image);
		TextView tv_capture_image = (TextView) findViewById(R.id.tv_capture_image);

		tv_local_image.setOnClickListener(this);
		tv_capture_image.setOnClickListener(this);
		
		getWindow().getAttributes().width = DensityUtil.dip2px(this.getContext(), 250);
		getWindow().getAttributes().dimAmount = 0.5f;
		getWindow().getAttributes().y = -DensityUtil.dip2px(this.getContext(), 40);
	}

	@Override
	public void onClick(View v) {
		dismiss();
		int id = v.getId();
		if (id == R.id.tv_local_image || id == R.id.tv_capture_image) {
			dismiss();
			if (mListener != null) {
				mListener.onClick(v);
			}
		}
	}
}
